package com.hyt.it.ogt.data;

import com.hyt.it.ogt.data.service.pj.IPjDataCommonAutomaticAllocationService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class PjIncrementDataDistribution implements Runnable {

    private final Logger log = LoggerFactory.getLogger(PjIncrementDataDistribution.class);

    private String pjProjectId;
    private IPjDataCommonAutomaticAllocationService iPjDataCommonAutomaticAllocationService;


    public String getPjProjectId() {
        return pjProjectId;
    }

    public void setPjProjectId(String pjProjectId) {
        this.pjProjectId = pjProjectId;
    }

    public IPjDataCommonAutomaticAllocationService getiCommonAutomaticAllocationService() {
        return iPjDataCommonAutomaticAllocationService;
    }

    public void setiCommonAutomaticAllocationService(IPjDataCommonAutomaticAllocationService iPjDataCommonAutomaticAllocationService) {
        this.iPjDataCommonAutomaticAllocationService = iPjDataCommonAutomaticAllocationService;
    }

    @Override
    public void run() {
        try {
            log.info("[推送评卷] increment distribution start pjProjectId:{}", pjProjectId);
            if (StringUtils.isNotEmpty(pjProjectId)) {
                iPjDataCommonAutomaticAllocationService.commonAutomaticAllocation(pjProjectId);
            }
            log.info("[推送评卷] increment distribution end pjProjectId:{}", pjProjectId);
        } catch (Exception e) {
            log.error("[推送评卷]increment distribution", e);
        }
    }
}
